﻿namespace Mvvm.Common
{
    public class LoadingModel:ViewModelBase
    {
        private string _loadingText; //加载文本
        private bool _isLoading; //是否加载中

        /// <summary>
        /// 是否加载中
        /// </summary>
        public bool IsLoading
        {
            get => _isLoading;
            set => SetProperty(ref _isLoading, value);
        }
        /// <summary>
        /// 加载文本
        /// </summary>
        public string LoadingText
        {
            get => _loadingText;
            set => SetProperty(ref _loadingText, value);
        }

        public LoadingModel():this(null)
        {

        }
        public LoadingModel(string loadingText)
        {
            _loadingText = loadingText;
        }
        /// <summary>
        /// 显示加载框
        /// </summary>
        /// <param name="loadingText"></param>
        public void ShowLoading(string loadingText)
        {
            IsLoading = true;
            LoadingText = loadingText;
        }
        /// <summary>
        /// 隐藏加载框
        /// </summary>
        public void HideLoading()
        {
            IsLoading = false;
        }
    }
}
